﻿@using VocaDb.Web.Helpers;
@using Res = ViewRes.Event.EventsBySeriesStrings
@inherits VocaDb.Web.Code.VocaDbPage<VocaDb.Model.DataContracts.ReleaseEvents.ReleaseEventSeriesWithEventsContract[]>

@{
	PageProperties.Title = ViewRes.SharedStrings.ReleaseEvents;
}

@section Toolbar {
	
	<ul class="nav nav-pills">
		<li>
			@Html.ActionLink(Res.ViewList, "Index")
		</li>
		<li class="active">
			@Html.ActionLink(Res.ViewBySeries, "EventsBySeries")
		</li>
		<li>
			@Html.ActionLink(Res.ViewByDate, "EventsByDate")
		</li>
	</ul>	

	@if (Login.CanManageDb) {
		@Html.ActionLink(Res.CreateEvent, "Edit", null, new { id = "createEventLink" })
		@:
		@Html.ActionLink(Res.CreateSeries, "EditSeries", null, new { id = "createSeriesLink" })
	}	
}

@foreach (var series in Model) {

	<div class="media withMargin">
		@if (!string.IsNullOrEmpty(series.PictureMime)) {
			<a class="pull-left" href="@Url.Action("SeriesDetails", new { id = series.Id })">
				<img class="media-object" src="@Url.ImageThumb(series, VocaDb.Model.Domain.Images.ImageSize.TinyThumb)" alt="Thumb" />
			</a>
		}
		<div class="media-body">
			<h3 class="media-heading">
				@if (!string.IsNullOrEmpty(series.Name)) {
					@Html.ActionLink(series.Name, "SeriesDetails", new { id = series.Id })
				} else {
					<text>@ViewRes.SharedStrings.Unsorted</text>
				}
			</h3>
						
			@if (!string.IsNullOrEmpty(series.Description)) {
				<p>@HtmlHelpers.FormatMarkdown(series.Description)</p>
			}
		</div>
	</div>
	
	<ul>
	@foreach (var ev in series.Events) {
		<li>
			@Html.ActionLink(ev.Name, "Details", new { id = ev.Id, slug = ev.UrlSlug })
		</li>
	}
	</ul>
	
	if (Login.CanManageDb) {
		@Html.ActionLink(Res.CreateEvent, "Edit", new { seriesId = series.Id != 0 ? (int?)series.Id : null }, new { @class = "textLink addLink" })
	}
	
}

@section BodyScripts {
	<script type="text/javascript">

		$(function () {
			$("#createEventLink").button({ icons: { primary: 'ui-icon-plus' } });
			$("#createSeriesLink").button({ icons: { primary: 'ui-icon-plus' } });
		});

	</script>
}